local scene = director:createScene()

function scene:setUp(event)
    dbg.print("sceneMenu:setUp")
	
	local scaleX = 320/director.displayWidth
	local scaleY = 480/director.displayHeight
	
	if (io.open("bestTimes.txt") == nil) then
		file = io.open("bestTimes.txt", "w")
		file:write("999".."\n")
		file:write("999".."\n")
		file:write("999".."\n")
		file:write("999".."\n")
		file:write("999".."\n")
		file:close()
	end
	
	local imageBalloons = director:createSprite(director.displayCenterX, director.displayHeight-20/scaleY, "img/imageballoons.png")
	imageBalloons.xAnchor=0.5; 
	imageBalloons.yAnchor=1;
	imageBalloons.xScale=1.3/scaleX
	imageBalloons.yScale=1.3/scaleY
	
	local buttonPlay = director:createSprite(director.displayCenterX, director.displayCenterY, "img/button.png")
	buttonPlay.xAnchor=0.5; buttonPlay.yAnchor=0.5
	buttonPlay.y = director.displayCenterY - buttonPlay.h/3/scaleY
	buttonPlay.yScale=.6/scaleY; 
	buttonPlay.xScale=1.3/scaleX;
	
	labelPlay = director:createLabel(director.displayCenterX, director.displayCenterY, "Play")
	labelPlay.xAnchor=0.5; 
	labelPlay.zOrder = buttonPlay.zOrder
	labelPlay. hAlignment="center"
	labelPlay.y = buttonPlay.y-10/scaleY
	labelPlay.xScale = 1/scaleX
	labelPlay.yScale = 1/scaleY
	labelPlay.color = color.black
		
	local buttonInstructions = director:createSprite(director.displayCenterX, director.displayCenterY, "img/button.png")
	buttonInstructions.xAnchor=0.5; buttonInstructions.yAnchor=0.5
	buttonInstructions.y =  director.displayCenterY - buttonInstructions.h/scaleY
	buttonInstructions.yScale=.6/scaleY; 
	buttonInstructions.xScale=1.3/scaleX;
	
	labelInstructions = director:createLabel(director.displayCenterX, director.displayCenterY, "Instructions")
	labelInstructions.xAnchor=0.5;
	labelInstructions.zOrder = buttonPlay.zOrder
	labelInstructions. hAlignment="center"
	labelInstructions.y = buttonInstructions.y-10/scaleY
	labelInstructions.xScale = 1/scaleX
	labelInstructions.yScale = 1/scaleY
	labelInstructions.color = color.black
	
	local buttonScore = director:createSprite(director.displayCenterX, director.displayCenterY, "img/button.png")
	buttonScore.xAnchor=0.5; buttonScore.yAnchor=0.5
	buttonScore.y =  director.displayCenterY - buttonScore.h/scaleY*5/3
	buttonScore.yScale=.6/scaleY; 
	buttonScore.xScale=1.3/scaleX;
	
	labelScore = director:createLabel(director.displayCenterX, director.displayCenterY, "Score")
	labelScore.xAnchor=0.5; 
	labelScore.zOrder = buttonScore.zOrder
	labelScore. hAlignment="center"
	labelScore.y = buttonScore.y-10/scaleY
	labelScore.xScale = 1/scaleX
	labelScore.yScale = 1/scaleY
	labelScore.color = color.black

	
	function buttonPlay:touch(event)
		if (event.phase == 'began') then
			selectGame = "Play"
			system:sendEvent("moveToSceneGame")
		end
	end
	buttonPlay:addEventListener('touch', buttonPlay)

	function buttonInstructions:touch(event)
		if (event.phase == 'began') then
			system:sendEvent("moveToSceneInstructions")
		end
	end
	buttonInstructions:addEventListener('touch', buttonInstructions)
	
	function buttonScore:touch(event)
		if (event.phase == 'began') then
			system:sendEvent("moveToSceneScore")
		end
	end
	buttonScore:addEventListener('touch', buttonScore)
end

function scene:tearDown(event)
    dbg.print("sceneMenu:tearDown")
end

scene:addEventListener({"setUp", "tearDown"}, scene)

return scene  -- We must return the scene object!